public class demo01 {
    public static void main(String[] args) {
        int[][] board = {{1, 0, 1}, {1, -1, -1}, {1, -1, 0}};
        System.out.println(checkWon(board));
    }

    //井字棋
    public static boolean checkWon(int[][] board) {
        int size = board.length;
        int sum = 0;
        int i = 0;
        int j = 0;
        for (i = 0; i < size; i++) {
            for (j = 0; j < size; j++) {
                sum += board[i][j];
            }
            if (sum == size) {
                return true;
            }
        }
        for (i = 0; i < size; i++) {
            sum = 0;
            for (j = 0; j < size; j++) {
                sum += board[j][i];
            }
            if (size == sum) {
                return true;
            }
        }
        sum = 0;
        for (i = 0; i < size; i++) {
            sum += board[i][i];
        }
        if (size == sum) {
            return true;
        }
        sum = 0;
        for (i = 0; i < size; i++) {
            sum += board[i][size - i - 1];
        }
        if (size == sum) {
            return true;
        }
        return false;
    }
}
